package 重要代码;

import java.util.Arrays;

public class 删除数组重复数 {
    public static void main(String[] args) {
        int[]arr={1,4,2,4,6,3};

//        int[]temp=delet(arr,4);
        System.out.println(Arrays.toString(delet(arr,4)));


    }

    public  static int[] delet(int[] arr,int element){
       if(arr == null || arr.length==0){
          return new int[]{-1};
       }
       int count=0;
        for (int i = 0; i <arr.length ; i++) {
            if(arr[i]==element){
                count++;
            }

        }
        if (count==0){
            return arr;

        }
      int[]temp=new int[arr.length-count];
        int pos=0;
        for (int i = 0; i <arr.length ; i++) {
            if (arr[i]!=element){
                temp[pos++]=arr[i];

            }

        }


        return temp;
    }
}
